{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "6d752823",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.08333333333333334"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from scipy.integrate import quad \n",
    "import numpy as np\n",
    "p=3\n",
    "q=2\n",
    "f=lambda x: x**(p-1)*(1-x)**(q-1) #贝塔函数\n",
    "quad(f, 0, 1)[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "c5391c27",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "24.0"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p=5\n",
    "g=lambda x: np.exp(-x)*x**(p-1)#伽马函数\n",
    "quad(g, 0, np.inf)[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "26d91b86",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
